<?php

namespace App\Http\Controllers\YApi;

//use Illuminate\Http\Request;
use Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;

use Session;
use Redirect;

use App\Models\UsersReg;
use App\Models\Bags;
use App\Models\Book;

class UsersBagsController extends Controller
{
	public function usersbags()
	{
		// 显示会员转让的书籍		
		$uid = request::input('uid');		
		$bags = Bags::where('uid', $uid)->orderBy('add_time', 'desc')->paginate(15);

		foreach($bags as $bag) {
			// 对应的书籍信息
			$bag['books'] = Book::find($bag->book_id);
		}

		foreach($bags as $bag) {
			// 对应的会员的信息
			$bag['users'] = UsersReg::find($uid);
		}

		return $bags;
	}
}
